#!/usr/bin/python
import getMpiVm
import delMpiVm
import db
import setMpiEnv
import launchMpiProm
import testMpi
import testVmIsAlive
import time

job_id = 0
while job_id <= 0:
    job_id =  getMpiVm.create(9,10,5)
    print job_id

flag = 0
testCnt = 0
while flag <= 0:
    flag = testVmIsAlive.checkVmIsAlive(job_id)
    testCnt += 1
    print "Vm Alive test ",testCnt, "th ans: ", flag
    time.sleep(30)

flag = 0
testCnt = 0

while flag <= 0:
    flag = setMpiEnv.setMpiEnv(job_id)
    testCnt += 1
    print "Set Env test ", testCnt, "th ans: ", flag
    time.sleep(5)


print "Test MpiEnv ans: ", testMpi.testmpi(job_id)

listFile=['/home/niumeng/API/a.c','/home/niumeng/API/b.c']
testCnt = 0
while testCnt < 10:
    testCnt += 1
    flag = launchMpiProm.launch(job_id,"./cpi.c",listFile)
    result = ""
    if flag > 0:
        flag1, result = launchMpiProm.getJobAns(flag)
    print testCnt, "th launch Job ans: ", flag, flag1, result
    

print delMpiVm.delJobs(job_id)



